package com.yanqu.road.entity.activity.liondance;

import com.yanqu.road.entity.activity.ActivityInfo;
import com.yanqu.road.entity.activity.liondance.config.LionDanceCardInfo;
import com.yanqu.road.entity.activity.liondance.config.LionDanceCombInfo;
import com.yanqu.road.entity.activity.liondance.config.LionDanceJumpConfigInfo;
import com.yanqu.road.utils.RandomHelper;
import com.yanqu.road.utils.string.StringUtils;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

public class LionDanceConfig {

    private ActivityInfo activityInfo;


    public ActivityInfo getActivityInfo() {
        return activityInfo;
    }

    private List<LionDanceJumpConfigInfo> jumpConfigInfoList;

    private List<LionDanceCardInfo> cardInfoList;

    private List<LionDanceCombInfo> combInfoList;

    //消耗道具ID
    private int consumeItemId;

    //舞狮加成值（累计进度千分比;分数加成）
    private String LIONDANCE_VALUE_ADD;

    //彩球桩奖励积分
    private List<Integer> LIONDANCE_COLOR_REWARD_SCORE;

    //彩球桩奖励积分权重
    private List<Integer> LIONDANCE_COLOR_WEIGHT;

    //彩球桩触发奖励时间
    private int LIONDANCE_COLOR_TIME;

    //每次跳跃的积分
    private int LIONDANCE_JUMP_SCORE = 10;

    //彩球桩奖励加成持续时间/S
    private int LIONDANCE_ADD_ITEM_CONTINUED_TIME = 10;

    public void setActivityInfo(ActivityInfo activityInfo) {
        this.activityInfo = activityInfo;
    }


    public List<LionDanceJumpConfigInfo> getJumpConfigInfoList() {
        return jumpConfigInfoList;
    }

    public void setJumpConfigInfoList(List<LionDanceJumpConfigInfo> jumpConfigInfoList) {
        this.jumpConfigInfoList = jumpConfigInfoList;
    }


    public List<LionDanceCardInfo> getCardInfoList() {
        return cardInfoList;
    }

    public void setCardInfoList(List<LionDanceCardInfo> cardInfoList) {
        this.cardInfoList = cardInfoList;
    }

    public List<LionDanceCombInfo> getCombInfoList() {
        return combInfoList;
    }

    public void setCombInfoList(List<LionDanceCombInfo> combInfoList) {
        this.combInfoList = combInfoList;
    }

    public int getConsumeItemId() {
        return consumeItemId;
    }

    public void setConsumeItemId(int consumeItemId) {
        this.consumeItemId = consumeItemId;
    }

    public String getLIONDANCE_VALUE_ADD() {
        return LIONDANCE_VALUE_ADD;
    }

    public void setLIONDANCE_VALUE_ADD(String LIONDANCE_VALUE_ADD) {
        this.LIONDANCE_VALUE_ADD = LIONDANCE_VALUE_ADD;
    }

    public List<Integer> getLIONDANCE_COLOR_REWARD_SCORE() {
        return LIONDANCE_COLOR_REWARD_SCORE;
    }

    public void setLIONDANCE_COLOR_REWARD_SCORE(List<Integer> LIONDANCE_COLOR_REWARD_SCORE) {
        this.LIONDANCE_COLOR_REWARD_SCORE = LIONDANCE_COLOR_REWARD_SCORE;
    }

    public List<Integer> getLIONDANCE_COLOR_WEIGHT() {
        return LIONDANCE_COLOR_WEIGHT;
    }

    public void setLIONDANCE_COLOR_WEIGHT(List<Integer> LIONDANCE_COLOR_WEIGHT) {
        this.LIONDANCE_COLOR_WEIGHT = LIONDANCE_COLOR_WEIGHT;
    }

    public int getLIONDANCE_COLOR_TIME() {
        return LIONDANCE_COLOR_TIME;
    }

    public void setLIONDANCE_COLOR_TIME(int LIONDANCE_COLOR_TIME) {
        this.LIONDANCE_COLOR_TIME = LIONDANCE_COLOR_TIME;
    }

    public LionDanceCardInfo getCardById(int cardId) {
        for (LionDanceCardInfo cardInfo : cardInfoList) {
            if(cardId == cardInfo.getId()){
                return cardInfo;
            }
        }
        return null;
    }

    public LionDanceCombInfo getLionDanceCombInfo(int comb){
        for (LionDanceCombInfo combInfo : combInfoList) {
            if(combInfo.getCombId() == comb){
                return combInfo;
            }
        }
        return null;
    }

    /**
     * 100=50;200=60
     */
    public int getWeightItem(String addItem, Random random) {
        List<String> configList = StringUtils.stringToStringList(addItem, ";");
        List<Integer> idList = new ArrayList<>();
        List<Integer> weightList = new ArrayList<>();
        for (String item : configList) {
            List<Integer> list = StringUtils.stringToIntegerList(item, "=");
            idList.add(list.get(0));
            weightList.add(list.get(1));
        }
        int index = RandomHelper.getRandomIndexByWeight(weightList, random);
        return idList.get(index);
    }

    public int getLIONDANCE_JUMP_SCORE() {
        return LIONDANCE_JUMP_SCORE;
    }

    public void setLIONDANCE_JUMP_SCORE(int LIONDANCE_JUMP_SCORE) {
        this.LIONDANCE_JUMP_SCORE = LIONDANCE_JUMP_SCORE;
    }

    public int getLIONDANCE_ADD_ITEM_CONTINUED_TIME() {
        return LIONDANCE_ADD_ITEM_CONTINUED_TIME;
    }

    public void setLIONDANCE_ADD_ITEM_CONTINUED_TIME(int LIONDANCE_ADD_ITEM_CONTINUED_TIME) {
        this.LIONDANCE_ADD_ITEM_CONTINUED_TIME = LIONDANCE_ADD_ITEM_CONTINUED_TIME;
    }
}
